<template>
  <div>
    <el-tree
      :data="emp"
      :props="props"
      node-key="id"
      default-expand-all
      :expand-on-click-node="false"
      :highlight-current="true"
    />
  </div>
</template>

<script>
import { getDepartmentsAPI } from '@/api/department'
import { transListToTreeData } from '@/utils/index'
export default {
  data() {
    return {
      emp: [],
      props: {
        children: 'children',
        label: 'name'
      }

    }
  },
  created() {
    this.getDepartments()
  },
  methods: {
    async getDepartments() {
      this.emp = transListToTreeData(await getDepartmentsAPI(), 0)
      // console.log(this.emp)
    }

  }
}
</script>
